/*
 *         (C) COPYRIGHT Ingenic Limited
 *              ALL RIGHT RESERVED
 *
 * File        : uranus_imgproc.h
 * Authors     :
 * Create Time : 2020-12-24 15:02:22 (CST)
 * Description :
 *
 */

#ifndef __MAGIK_URANUS_UTILS_IMGPROC_H__
#define __MAGIK_URANUS_UTILS_IMGPROC_H__
#include "common/common_utils.h"
#include "common/common_utils_nriscv.h"
#include "core/uranus_tensor.h"
#include "imgproc_type.h"
#include <vector>
namespace magik {
namespace uranus {
ALG_PACK_START
/*
 * similar transform
 * input_src : input tensor, source perspective matrix
 * input_dst : input tensor, dst perspective matrix
 * output : output tensor, similar transform result matrix
 * retval : 0, success, <0 failed
 */
URANUS_API int similar_transform(Tensor &input_src, Tensor &input_dst, Tensor &output);
/*
 * crop and affine input nv12 or bgra or gray format data
 * output: output tensor
 * matrix: matrix tensor
 * boxes: boxes for input nv12 or bgra format data crop
 * input_locate: NMEM_VIRTUAL
 * param: resize param: vir_addr and phy_addr
 */
URANUS_API int crop_common_affine(std::vector<Tensor> &output, std::vector<Tensor> &matrix,
                                  std::vector<Bbox_t> &boxes, AddressLocate input_locate,
                                  BsCommonParam *param);
URANUS_API int crop_common_affine(std::vector<Tensor> &output, std::vector<Tensor> &matrix,
                                  std::vector<Bbox_t> &boxes, AddressLocate input_locate,
                                  BsCommonParam *param, bool param_check);
/*
 * crop and perspective input nv12 or bgra or gray format data
 * output: output tensor
 * matrix: matrix tensor
 * boxes: boxes for input nv12 or bgra format data crop
 * input_locate: NMEM_VIRTUAL
 * param: resize param: vir_addr and phy_addr
 */
URANUS_API int crop_common_perspective(std::vector<Tensor> &output, std::vector<Tensor> &matrix,
                                       std::vector<Bbox_t> &boxes, AddressLocate input_locate,
                                       BsCommonParam *param);
URANUS_API int crop_common_perspective(std::vector<Tensor> &output, std::vector<Tensor> &matrix,
                                       std::vector<Bbox_t> &boxes, AddressLocate input_locate,
                                       BsCommonParam *param, bool param_check);
/*
 * crop and resize input nv12 or bgra format data
 * output: output tensor
 * boxes: boxes for input nv12 or bgra format data crop
 * input_locate: NMEM_VIRTUAL
 * param: resize param: vir_addr and phy_addr
 */
URANUS_API int crop_common_resize(std::vector<Tensor> &output, std::vector<Bbox_t> &boxes,
                                  AddressLocate input_locate, BsCommonParam *param);
URANUS_API int crop_common_resize(std::vector<Tensor> &output, std::vector<Bbox_t> &boxes,
                                  AddressLocate input_locate, BsCommonParam *param,
                                  bool param_check);
URANUS_API int opencv_crop_common_resize(std::vector<Tensor> &output, std::vector<Bbox_t> &boxes,
                                         AddressLocate input_locate, BsCommonParam *param);
URANUS_API int opencv_crop_common_resize(std::vector<Tensor> &output, std::vector<Bbox_t> &boxes,
                                         AddressLocate input_locate, BsCommonParam *param,
                                         bool param_check);
/*
 * convert func
 * input : input tensor NV12
 * output: output tensor RGBA/BGRA
 * param : coef_off_enable,coef,offset,out_layout
 */
URANUS_API int warp_convert_color(Tensor &input, Tensor &output, BsCommonParam *param);

/*just support nv12 to bgra*/

URANUS_API int warp_convert_color_simd(Tensor &input, Tensor &output, BsCommonParam *param);

/*
 * nhwc4 to nhwc3 || nhwc3 to nhwc4
 */
URANUS_API int img_convert(Tensor &input, Tensor &output);

/*
 * just support nv12 to bgra
 */
URANUS_API int common_convert_simd(Tensor &output, BsCommonParam *param);
ALG_PACK_END
} // namespace uranus
} // namespace magik
#endif /* __MAGIK_URANUS_UTILS_IMGPROC_H__ */
